﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
using Trackr.Helpers;

namespace Trackr.ViewModel
{
	public abstract class BaseViewModel<T> : INotifyPropertyChanged where T : Window
	{
		private Dictionary<string, RelayCommand> _dic = new Dictionary<string, RelayCommand>();
		internal RelayCommand Execute(string key, Action<object> command)
		{
			if (_dic.ContainsKey(key))
				return _dic[key];
			var cmd = new RelayCommand(command);
			_dic.Add(key, cmd);
			return cmd;
		}
		public T View { get; set; }
		public Dispatcher Dispatcher
		{
			get { return Application.Current.Dispatcher; }
		}
		public App CurrentApp
		{
			get { return App.Current as App; }
		}

		public event PropertyChangedEventHandler PropertyChanged;
		protected void OnNotifyPropertyChanged(string propertyName)
		{
			if (PropertyChanged != null)
				PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
		}

	}
}
